package com.ws.q1.service.lmpl;

import com.ws.q1.bean.User;
import com.ws.q1.mapper.HouTaiUserMapper;
import com.ws.q1.service.HouTaiUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HouTaiUserlmpl implements HouTaiUserService {
    @Autowired
    private HouTaiUserMapper houTaiUserMapper;

    @Override
    public int add(String name, String pass, String phone, String tou) {
        return houTaiUserMapper.add(name, pass, phone, tou);
    }

    @Override
    public List<User> list() {
        return houTaiUserMapper.list();
    }

    @Override
    public int deleteById(Integer id) {
        houTaiUserMapper.deleteById(id);
        return 1; // 返回1表示删除成功
    }

    @Override
    public void update(Integer id, User user) {
        houTaiUserMapper.update(id, user);
    }

    @Override
    public User huixian(Integer id) {
        return houTaiUserMapper.huixian(id);
    }

    @Override
    public boolean isUsernameExists(String name) {
        return houTaiUserMapper.isUsernameExists(name) > 0;
    }

    @Override
    public List<User> getAllUsers() {
        return houTaiUserMapper.getAllUsers();
    }

    @Override
    public List<User> getUsersByName(String name) {
        return houTaiUserMapper.getUsersByName(name);
    }
}
